<?php
/**
 * Created by PhpStorm.
 * User: song
 * Date: 2018/9/11
 * Time: 下午8:41
 */

if (!defined('__APP__')) {
    var_dump('请从入口文件访问');
}
define("__MODEL__", __APP__ . "/model/");
define("__SERVER__", __APP__ . "/service/");


require_once QingPHP_PATH . "/Common/function.php";
require_once QingPHP_PATH . "/Common/config.php";
require_once __APP__ . "/configs/config.php";


// 定义Model类加载方式
function loadModel($classname)
{
    $classname = str_replace("\\", "/", $classname);
    $filename = $classname . ".php";
    if (file_exists($filename)) {
        require_once $filename;
    } else {
        addlog(["文件加载错误", $filename]);
    }
}

// 定义Controller加载方式
function loadService($classname)
{
    $classname = ucfirst($classname);
    $filename = dirname(__APP__) . "/" . $classname . '.php';
    //路径全部转为小写，并且使用Linux拼接符合
    $filename = str_replace("\\", "/", strtolower($filename));

    if (file_exists($filename)) {
        require $filename;
    }

}

// 注册两个加载函数
spl_autoload_register("loadModel");
//spl_autoload_register("loadService");


